Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

231
Vistas
Why passing data through Vue-router returning "[object Object]"?

What I'm trying to do is to pass some data from one component to another via router (I'm using Vue-Router-4 with Vue 3.0). But the data that I'm getting back is just "[object Object]" instead of the actual value. Here is what I did. Inside the component that sends the data I have this function

goToQuestions() {
  this.$router.push({
    name: "QuestionsPage",
    params: {
      data: this.questions
    },
  });
},

inside my index.js I have this

{
  path: "/questions-page",
  name: "QuestionsPage",
  props: true,
  component: () =>
    import ('@/views/QuestionsPage.vue')
},

And then inside the receiver component I have this snippet

props: ["data"],
  mounted() {
    console.log("data coming from the router", this.data);
  },

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I am assuming you this.questions is either array or object.

with router it is advised not to send objects and arrays. Instead send an id . And on the receiver page use that id to fetch the data.

Even if you want to pass object you can try this:

when adding routes, use props's Function mode so that it has a default property user and it will add route.params as props.

{
    path: '/questions',
    name: 'questions',
    component: QuestionsComponent,
    props: (route) => ({
        user: userData,
        ...route.params
    })
}

use this to push into your route

self.$router.push({
    name: 'questions',
    params: {
        data: this.questions
    }
})
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda